package souhu;

import java.util.Arrays;
import java.util.Scanner;

/**
 * Description：
 * Author: zhangc
 * Date：2017/9/17 10:32
 */
public class BigNum {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int i = scanner.nextInt();
        int[] arr = new int[i];
        for (int j = 0; j < i; j++) {
            arr[j] = scanner.nextInt();
        }
        if (i <= 1) {
            System.out.println(-1);
            return;
        }
        Arrays.sort(arr);
        System.out.println(arr[i-2]);
    }

}
